<%-- 
    Document   : register
    Created on : Apr 24, 2012, 1:23:11 PM
    Author     : acer
--%>
<%@page import="java.io.*"%>
<%@page import="java.net.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:include page="header.jsp"/>
<%!
   
    public String parseErrorMessage(int error)
    {
            switch(error){
                case 1 : return "*username kurang dari 5 karakter";
                case 2 : return "*password kurang dari 8 karakter";
                case 3 : return "*username tidak boleh sama dengan password";
                case 4 : return "*password tidak boleh sama dengan email";
                case 5 : return "*konfirmasi password tidak cocok";
                case 6 : return "*nama lengkap tidak valid";
                case 7 : return "*tanggal lahir tidak valid";
                case 8 : return "*email tidak valid";
                case 9 : return "*avatar tidak valid";
                case 10 : return "*gender belum dipilih";
                case 11 : return "*gagal meng-upload file, silakan ulangi kembali";
                case 12 : return "*username sudah terdaftar";
                case 13 : return "*email sudah terdaftar";
                default: return "no error";
            }
    }
%>
<!-- Body -->
	<div id="bodycontent">
	  <div class="contentcontainer">

		<div class="title-text">
		  <h1>Mendaftar</h1>
		</div>

		<div class="contentbox">
		<div class="error_message">
                    <%
                    //out.println(request.getParameter("test"));
                    String errormsg = request.getParameter("err_msg");
                    if(errormsg != null && !errormsg.isEmpty())
                    {
                        String[] err = errormsg.split("\\|");
                        for(String err_msg : err)
                        {
                            String message = parseErrorMessage(Integer.parseInt(err_msg));
                            out.print(message+"<br/>");
                            
                        }
                    }

%>


		</div>
        <form method="POST" action="Register" enctype="multipart/form-data">
		  <div class="form-element1">Username:</div>
                  <div class="form-element2"><input class="inputbox" type="text" name="username" size="35" <%out.println((request.getParameter("username")!=null)? "value="+request.getParameter("username"):"");%> /></div>
		  <br/>
		  <div class="form-element1"></div>
		  <div class="form-element2"><small>(Minimal 5 karakter. Tidak boleh sama dengan password)</small></div>
		  <br/>
		  <div class="form-element1">Password:</div>
		  <div class="form-element2"><input class="inputbox" type="password" name="password" size="20"/></div>
		  <br/>
		  <div class="form-element1"></div>
		  <div class="form-element2"><small>(Minimal 8 karakter. Tidak boleh sama dengan username atau email)</small></div>
		  <br/>
		  <div class="form-element1">Confirm Password:</div>
		  <div class="form-element2"><input class="inputbox" type="password" name="confirm_password"  size="20"/></div>
		  <br/>
		  <div class="form-element1">Real Name:</div>
		  <div class="form-element2"><input class="inputbox" type="text" name="real_name" size="35" <%out.println((request.getParameter("real_name")!=null)? "value="+request.getParameter("real_name"):"");%> /></div>
		  <br/>
		  <div class="form-element1"></div>
		  <div class="form-element2"><small>(Minimal terdiri dari dua kata)</small></div>
		  <br/>
		  <div class="form-element1">Birthday:</div>
		  <div class="form-element2"><input class="inputbox" type="text" name="birthday" size="35" <%out.println((request.getParameter("birthday")!=null)? "value="+request.getParameter("birthday"):"");%> /></div>
		  <br/>
		  <div class="form-element1"></div>
		  <div class="form-element2"><small>(Format: YYYY-MM-DD)</small></div>
		  <br/>
		  <div class="form-element1">Email:</div>
		  <div class="form-element2"><input class="inputbox" type="text" name="email" size="35" <%out.println((request.getParameter("email")!=null)? "value="+request.getParameter("email"):"");%> /> </div>
		  <br/>
		  <div class="form-element1">Avatar:</div>
		  <div class="form-element2"><input type="file" name="avatar" size="35"/></div>
		  <br/>
		  <div class="form-element1"></div>
		  <div class="form-element2"><small>(Hanya .jpg atau .jpeg)</small></div>
		  <br/>
		  <div class="form-element1">Gender:</div>
		  <div class="form-element2">
		  <select name="sex">
			<option value="select_gender">Select Gender:</option>
			<option value="male">Male</option>
			<option value="female">Female</option>
		  </select>
	      </div>
		  <br/>
	      <div class="form-element1">About me (Optional):</div>
		  <br/>
		  <div class="form-element1"><textarea rows="5" cols="35" name="about" value=<%out.println((request.getParameter("about")!=null)? request.getParameter("about"):"");%>></textarea></div>
		  <br/>
	      <div class="form-element1">
		  <input type="submit" id="register" value="Register"/>
		 </div>
		  <br/>
                  </form>
            </div>
	  </div>
	</div>

<jsp:include page="footer.jsp"/>